crypto: support deterministic ECDSA/DSA signatures#62252
crypto: support deterministic ECDSA/DSA signatures#62252panva wants to merge 2 commits intonodejs:mainfrom
Conversation
Add dsaNonceType option to sign/verify node:crypto APIs. When set to 'deterministic', uses deterministic digital signature generation procedure per RFC 6979.
|
Review requested:
|
|
Leaving this at draft PR unless there's user interest. |
|
cc @paulmillr you might be interested / have an opinion on this |
See RFC6979 3.6 and https://paulmillr.com/posts/deterministic-signatures/. The suggestion is to switch to deterministic by default + add an ability to pass either specific randomness Buffer, or make node auto-generate random buffer:
|
|
|
https://docs.openssl.org/master/man7/provider-signature/#signature-parameters > OSSL_SIGNATURE_PARAM_NONCE_TYPE that's what this is, exposed as an opt-in option, not a new default IIUC there are no other options available to us |
|
The question is about how "random nonces" work, not about how deterministic one works Upd:
This is... bad. |
|
0 / random = current behaviour, csprng -> k, not changed by this PR noisy / hedged is not an option in OpenSSL, draft-irtf-cfrg-det-sigs-with-noise would need to be finished and published as RFC first for OpenSSL to consider it. |
|
@ChALkeR @paulmillr @nodejs/crypto is there interest in pursuing this PR further? |
|
V26 is around the corner, right? Could the default deterministic version be included there? |
|
We should introduce the option to have it first and then figure out a way to change a default. Doing so for 26 isn't realistic. OpenSSL version isn't a given, OpenSSL itself isn't a given, embedders of Node.js like electron use BoringSSL, so do Node.js-compat modes in Bun and workerd. We'll have to figure all that out. So my question is, is having the option to as per this PR an improvement worth pursuing, knowing that it is a stepping stone to possibly having it a default in the future. |
Also, once hedged are supported, users likely should not have an option to use CSPRG -> k anymore, |
Good question. Possibly, it may even be its very default. I would have to check.
Yes, if Hedged/Noisy would eventually be supported in OpenSSL I would make that the default over current random with no hesitation since it's not observable. But is that draft even going to progress? In the meantime, is "deterministic" option useful? |
|
bitcoin-core maintainers consider openssl bad and switched away a long time ago. Other consumers seems to be fine with randomness (they don't know it's fragile). If they don't know about fragility, they aren't likely to enable the flag manually. ed25519 and ed448 are already deterministic. So, mostly p256, p384, p521 curve users. It's useful but not too useful. Boringssl code doesn't seem to mention RFC6979 anywhere. |
|
Oh how fun, OpenSSL default BN_generate_dsa_nonce > ossl_bn_gen_dsa_nonce_fixed_top |
|
Great news. Then the PR is worth it. |
|
Is it? Because all it would do is introduce a "deterministic" option on top of what we know is a better default that's already in place. |
|
Yes. Deterministic option is still useful for those who want to align to specific test vectors / implementations. It's good. |
|
now, the docs are clear this new |
Add dsaNonceType option to sign/verify node:crypto APIs. When set to 'deterministic', uses deterministic digital signature generation procedure per RFC 6979.